package edu.sjtu.erplab.orips.webservice.client.collaborativemodulef;

public class CollaborativeModuleWebServiceInvoker {

	public static String createOneCollaborativeModule(String templateId,
			String businessType, String updateType) throws Exception {

		String result = "fail";
		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub binding = null;
		try {
			binding = (edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub) new edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceLocator()
					.getICollaborativeModuleWebServicePort();
		} catch (javax.xml.rpc.ServiceException jre) {
			if (jre.getLinkedCause() != null)
				jre.getLinkedCause().printStackTrace();
		}

		// Time out after a minute
		binding.setTimeout(60000);

		// Test operation
		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.CollaborativeModule value = null;
		value = binding.createOneCollaborativeModule(templateId, businessType,
				updateType);
		// TBD - validate results
		if (value != null) {
			System.out.println("createOneCollaborativeModule successfully !");
			result = "success";
		}
		return result;

	}

	public static String updateCollaborativeModuleByTemplateId(
			String templateId, String processKey, String jpdlXml,
			String componentXml) throws Exception {

		String result = "fail";
		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub binding = null;
		try {
			binding = (edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub) new edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceLocator()
					.getICollaborativeModuleWebServicePort();
		} catch (javax.xml.rpc.ServiceException jre) {
			if (jre.getLinkedCause() != null)
				jre.getLinkedCause().printStackTrace();
		}

		// Time out after a minute
		binding.setTimeout(60000);

		// Test operation
		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.CollaborativeModule value = null;
		value = binding.updateCollaborativeModuleByTemplateId(templateId,
				processKey, jpdlXml, componentXml);
		// TBD - validate results
		if (value != null) {
			result = "success";
			System.out
					.println("updateCollaborativeModuleByTemplateId successfully !");
		}

		return result;
	}

	public static String updateCollaborativeModuleBy3Params(String templateId,
			String businessType, String updateType, String processKey,
			String jpdlXml, String componentsXml) throws Exception {

		String result = "fail";

		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub binding = null;
		try {
			binding = (edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceSoapBindingStub) new edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.ICollaborativeModuleWebServiceServiceLocator()
					.getICollaborativeModuleWebServicePort();
		} catch (javax.xml.rpc.ServiceException jre) {
			if (jre.getLinkedCause() != null)
				jre.getLinkedCause().printStackTrace();
		}

		// Time out after a minute
		binding.setTimeout(60000);

		// Test operation
		edu.sjtu.erplab.orips.webservice.client.collaborativemodulef.CollaborativeModule value = null;
		value = binding.updateCollaborativeModuleBy3Params(templateId,
				businessType, updateType, processKey, jpdlXml, componentsXml);
		// TBD - validate results
		if (value != null) {
			result = "success";
			System.out
					.println("updateCollaborativeModuleBy3Params successfully !");
		}
		return result;
	}

	public static void main(String args[]) throws Exception {
//		createOneCollaborativeModule("14201", "TEMPLATE_SERVICE_UPDATEBYID",
//				"system");
//		String processXml = "<?xml version='1.0' encoding='UTF-8'?><Services><component><componentNo>14100</componentNo>"
//				+ "<beforeComponentNo>0000000</beforeComponentNo><nextComponentNo>0000002A</nextComponentNo>"
//				+ "<serviceTag>create order</serviceTag>"
//				+ "<serviceURL>http://172.30.20.79:8080/fhis_distr2/ws/orderAccessInputWS?wsdl</serviceURL>"
//				+ "<httpURL>http://172.30.0.72:7001/app.jsp</httpURL>"
//				+ "<serviceName>OrderAccessInputWSService</serviceName>"
//				+ "<servicePort>orderAccessInputWSPort</servicePort>"
//				+ "<namespaceURL>SERVICE_URL</namespaceURL><componentTitle>下订单</componentTitle>"
//				+ "<httpURL>http://172.30.0.72:7001/app.jsp</httpURL><componentName>OrderComponent</componentName>"
//				+ "<inputInterface>input</inputInterface><outputInterface>output</outputInterface>"
//				+ "<component><componentNo>14052</componentNo><beforeComponentNo>0000001B</beforeComponentNo>"
//				+ "<nextComponentNo>0000003A</nextComponentNo><serviceTag>approve order</serviceTag>"
//				+ "<serviceURL>http://172.30.20.81:8080/TMS_DEV_SAAS_TEST/services/OrderInputWebservices?wsdl</serviceURL>"
//				+ "<httpURL>http://172.30.20.79:8080/fhis_distr2/opi/OpiOrderAccAction.opi?method=doOrderAcc</httpURL>"
//				+ "<serviceName>OrderInputWebservices</serviceName><servicePort>OrderInputWebservicesHttpPort</servicePort>"
//				+ "<namespaceURL>SERVICE_PORT</namespaceURL><componentTitle>订单审核</componentTitle>"
//				+ "<componentName>confirmationComponent</componentName><inputInterface>input</inputInterface>"
//				+ "<outputInterface>output</outputInterface></component></component></Services>";
//		updateCollaborativeModuleByTemplateId("14201", "processKey_0001",
//				processXml, processXml);
		
		updateCollaborativeModuleBy3Params("111", "rrr", "rrr", "rrrr", "rrr", "rrr");

	}

}
